package jdk7demo3;

import java.util.Calendar;

public class Test1 {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();

        Date d = new Date(0L);
        c.setTime(d);
        c.set(Calendar.YEAR, 2023);
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        int week = c.get(Calendar.DAY_OF_WEEK);
        System.out.println(year + "年" + (month + 1) + "月" + day + "日");
        System.out.println(getWeek(week));

        System.out.println("-----------------");
    }

    public static String getWeek(int index) {
        String[] arr = {"", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
        return arr[index];
    }
}

class Date extends java.util.Date {
    private long time;

    public Date() {
    }

    public Date(long time) {
        this.time = time;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "Date{" + "time=" + time + '}';
    }

}